import { createWebHistory, createRouter, RouteRecordRaw } from 'vue-router'
import layout from '@/layout/index.vue'
const history = createWebHistory()

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: '/',
    component: layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        name: 'home',
        meta: { title: '首页', icon: 'data-model' },
        component: () => import('../view/home/index.vue')
      },
      {
        path: '/data-management',
        name: 'data-management',
        meta: { title: '数据管理', icon: 'data-source' },
        component: () => import('../view/data-management/index.jsx'),
        redirect: '/data-source',
        children: [
          {
            path: '/data-source',
            name: 'data-source',
            meta: { title: '数据源' },
            component: () => import('../view/data-management/data-source.jsx')
          },
          {
            path: '/data-model',
            name: 'data-model',
            meta: { title: '数据模型' },
            component: () => import('../view/data-management/data-model.jsx')
          }
        ]
      },
      {
        path: '/draggable',
        name: 'draggable',
        meta: { title: '大屏管理', hidde: true, icon: 'big' },
        component: () => import('../view/draggable/index.vue')
      }
    ]
  },
  {
    path: '/data-model-details',
    name: 'data-model-details',
    meta: { title: '数据源配置' },
    component: () => import('../view/data-management/details/data-model-details.vue')
  },
  {
    path: '/screen',
    name: 'screen',
    meta: { title: '数据源配置' },
    component: () => import('../view/screen/index.vue'),
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        meta: { title: '仪表盘' },
        component: () => import('../view/screen/dashboard.vue')
      },
      {
        path: '/dashboard-preview',
        name: 'dashboard-preview',
        meta: { title: '仪表盘预览' },
        component: () => import('../view/screen/dashboard-preview.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../view/login/index.vue')
  }
]
const router = createRouter({
  history,
  routes: routes
})
export default router
